<?php if(!defined('SIDELOADED')) { echo 'Direct access is not allowed.'; }

/**
 * Create an HTML list out of a PHP array.
 * @param array $array An array.
 * @param string $type The kind of list. Defaults to "ul".
 * @param int $whitespace The amount of whitespace to put in front of the list.
 * @return string The HTML list.
 */
function listify($array, $type = 'ul', $whitespace = 0) {
  
  $w = '';
  
  if($whitespace > 0) {
    
    for($i = 0; $i < $whitespace; $i++) {
      
      $w .= ' ';
      
    }
    
  }
  
  $return = $w . '<' . $type . '>';
  
  foreach($array as $item) {
    
    $return .= "\n" . $w . '  <li>' . $item . '</li>';
    
  }
  
  $return .= "\n" . $w . '</' . $type . '>';
  
  return $return;
  
}
